package com.gin.no_gay_alliance.adpter.emote;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.gin.no_gay_alliance.adpter.base.BaseBindingRecyclerViewAdapter;
import com.gin.no_gay_alliance.databinding.ItemEmoteBinding;
import com.gin.no_gay_alliance.utils.ImageUtils;
import com.gin.no_gay_alliance.viewmodel.emote.EmoteModel;

import java.util.List;

/**
 * 表情
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/8/30 14:39
 **/
public class EmoteItemAdapter extends BaseBindingRecyclerViewAdapter<ItemEmoteBinding, EmoteModel> {
    final View.OnClickListener onClickListener;

    public EmoteItemAdapter(Context context, View.OnClickListener listener) {
        super(context);
        onClickListener = listener;
    }

    public EmoteItemAdapter(@NonNull Context context, @NonNull List<EmoteModel> data, View.OnClickListener listener) {
        super(context, data);
        onClickListener = listener;
    }

    @Override
    protected void onBindViewHolder(ViewHolder<ItemEmoteBinding> holder, @NonNull ItemEmoteBinding b, int position, EmoteModel item) {
        ImageView iv = b.getRoot();
        ImageUtils.loadForumAvatar(context, item.url, iv);
        iv.setOnClickListener(onClickListener);
        // 将bbsCode放入tag
        iv.setTag(item.code);
    }

    @NonNull
    @Override
    protected ItemEmoteBinding buildBinding(LayoutInflater inflater) {
        return ItemEmoteBinding.inflate(inflater);
    }

    @Override
    protected boolean useZebraStripe() {
        return false;
    }
}
